/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ProjetoCompreJa.GUI;

import br.com.classesbasicas.Endereco;
import br.com.classesbasicas.Funcionario;
import ProjetoCompreJa.Fachada;
import java.util.List;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Marcos
 */
public class ExcluirAlterarFuncionario extends javax.swing.JFrame {

    private List<Funcionario> funcionarios;

    /**
     * Creates new form ExcluirFuncionario
     */
    public ExcluirAlterarFuncionario() {
        initComponents();
        OcultarAlterar();
        jComboBoxCidade.enable(false);
        jLabelCodigo.setVisible(false);

    }

    private void OcultarAlterar() {
        jLabel1.setVisible(false);
        jLabel2.setVisible(false);
        jLabel3.setVisible(false);
        jLabel4.setVisible(false);
        jLabel5.setVisible(false);
        jLabel6.setVisible(false);
        jLabel7.setVisible(false);
        jLabel8.setVisible(false);
        jLabel9.setVisible(false);
        jLabel10.setVisible(false);
        jLabel11.setVisible(false);
        jLabel12.setVisible(false);
        jLabel13.setVisible(false);
        jLabel14.setVisible(false);
        jLabel16.setVisible(false);
        jTextFieldBairro.setVisible(false);
        jTextFieldCPF.setVisible(false);
        jTextFieldLogradouro.setVisible(false);
        jTextFieldNome.setVisible(false);
        jTextFieldRG.setVisible(false);
        jTextFieldSalario.setVisible(false);
        jTextFieldComplemento.setVisible(false);
        jTextFieldNumero.setVisible(false);
        jComboBoxCidade.setVisible(false);
        jComboBoxEstado.setVisible(false);
        jComboBoxCargo.setVisible(false);
        jComboBoxSexo.setVisible(false);
        jButtonOK.setVisible(false);
        jButtonVoltar.setVisible(false);
        jSeparator1.setVisible(false);
        jSeparator2.setVisible(false);
        jSeparator4.setVisible(false);
        jButtonSalvar.setVisible(false);
        jButtonCancelar.setVisible(false);

    }

    private void ExibirAlterar() {
        jLabel1.setVisible(true);
        jLabel2.setVisible(true);
        jLabel3.setVisible(true);
        jLabel4.setVisible(true);
        jLabel5.setVisible(true);
        jLabel6.setVisible(true);
        jLabel7.setVisible(true);
        jLabel8.setVisible(true);
        jLabel9.setVisible(true);
        jLabel10.setVisible(true);
        jLabel11.setVisible(true);
        jLabel12.setVisible(true);
        jLabel13.setVisible(true);
        jLabel14.setVisible(true);
        jLabel16.setVisible(true);
        jTextFieldBairro.setVisible(true);
        jTextFieldCPF.setVisible(true);
        jTextFieldLogradouro.setVisible(true);
        jTextFieldNome.setVisible(true);
        jTextFieldRG.setVisible(true);
        jTextFieldSalario.setVisible(true);
        jTextFieldComplemento.setVisible(true);
        jTextFieldNumero.setVisible(true);
        jComboBoxCidade.setVisible(true);
        jComboBoxEstado.setVisible(true);
        jComboBoxCargo.setVisible(true);
        jComboBoxSexo.setVisible(true);
        jButtonOK.setVisible(true);
        jButtonVoltar.setVisible(true);
        jSeparator1.setVisible(true);
        jSeparator2.setVisible(true);
        jSeparator4.setVisible(true);
        jButtonCancelar.setVisible(true);
        jButtonSalvar.setVisible(true);
    }

    public void ListarFuncionarios() {
        try {

            DefaultTableModel modelo = new DefaultTableModel();
            modelo.setColumnIdentifiers(new String[]{"Nome", "CPF", "Salario"});
            Fachada f = new Fachada();
            this.funcionarios = f.ListarFuncionarios();
            for (int i = 0; i < funcionarios.size(); i++) {
                modelo.addRow(new Object[]{funcionarios.get(i).getNome(),
                    funcionarios.get(i).getCpf(),
                    funcionarios.get(i).getSalario()});
            }

            jTableFuncionario.setModel(modelo);
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane, ex.getMessage());

        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTableFuncionario = new javax.swing.JTable();
        jTextFieldNome = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTextFieldCPF = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jTextFieldRG = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldLogradouro = new javax.swing.JTextField();
        jTextFieldBairro = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jComboBoxEstado = new javax.swing.JComboBox();
        jComboBoxCidade = new javax.swing.JComboBox();
        jButtonOK = new javax.swing.JButton();
        jButtonVoltar = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jTextFieldSalario = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jComboBoxSexo = new javax.swing.JComboBox();
        jLabel11 = new javax.swing.JLabel();
        jComboBoxCargo = new javax.swing.JComboBox();
        jLabel13 = new javax.swing.JLabel();
        jTextFieldComplemento = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jTextFieldNumero = new javax.swing.JTextField();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        jSeparator4 = new javax.swing.JSeparator();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jButtonSalvar = new javax.swing.JButton();
        jButtonCancelar = new javax.swing.JButton();
        jLabelCodigo = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setType(java.awt.Window.Type.UTILITY);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jTableFuncionario.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTableFuncionario.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableFuncionarioMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTableFuncionario);

        getContentPane().add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 70, 564, 130));
        getContentPane().add(jTextFieldNome, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 280, 110, -1));

        jLabel1.setText("Nome:");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 280, -1, -1));

        jLabel2.setText("CPF:");
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 320, -1, -1));
        getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 342, -1, -1));
        getContentPane().add(jTextFieldCPF, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 320, 110, -1));

        jLabel4.setText("RG:");
        getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 360, -1, -1));
        getContentPane().add(jTextFieldRG, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 360, 110, -1));

        jLabel5.setText("Logradouro:");
        getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 280, -1, -1));

        jLabel6.setText("Estado:");
        getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 440, -1, -1));

        jLabel7.setText("Cidade:");
        getContentPane().add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 490, -1, -1));
        getContentPane().add(jTextFieldLogradouro, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 280, 250, -1));

        jTextFieldBairro.setToolTipText("");
        getContentPane().add(jTextFieldBairro, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 360, 110, -1));

        jLabel8.setText("Bairro:");
        getContentPane().add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 360, -1, -1));

        jComboBoxEstado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxEstadoActionPerformed(evt);
            }
        });
        getContentPane().add(jComboBoxEstado, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 440, 185, -1));

        getContentPane().add(jComboBoxCidade, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 490, 185, -1));

        jButtonOK.setText("OK");
        jButtonOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonOKActionPerformed(evt);
            }
        });
        getContentPane().add(jButtonOK, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 210, 73, 20));

        jButtonVoltar.setText("Voltar");
        getContentPane().add(jButtonVoltar, new org.netbeans.lib.awtextra.AbsoluteConstraints(520, 210, 73, 20));

        jButton1.setText("Testar(Listar)");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 210, -1, 20));

        jLabel9.setText("Salario:");
        getContentPane().add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 400, -1, -1));
        getContentPane().add(jTextFieldSalario, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 400, 53, -1));

        jLabel10.setText("Sexo:");
        getContentPane().add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 440, -1, -1));

        jComboBoxSexo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecione", "Masculino", "Feminino" }));
        getContentPane().add(jComboBoxSexo, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 440, -1, -1));

        jLabel11.setText("Cargo:");
        getContentPane().add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 490, -1, -1));

        jComboBoxCargo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { " ", "Gestor Cliente", "Gestor Produto" }));
        getContentPane().add(jComboBoxCargo, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 490, -1, -1));

        jLabel13.setText("Complemento:");
        getContentPane().add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 320, -1, -1));
        getContentPane().add(jTextFieldComplemento, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 320, 250, -1));

        jLabel12.setText("Numero:");
        getContentPane().add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 400, -1, -1));

        jTextFieldNumero.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldNumeroActionPerformed(evt);
            }
        });
        getContentPane().add(jTextFieldNumero, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 400, 47, -1));
        getContentPane().add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 270, 590, 10));

        jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);
        getContentPane().add(jSeparator2, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 240, 20, 300));
        getContentPane().add(jSeparator4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 240, 590, 10));

        jLabel14.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel14.setText("Endereço");
        getContentPane().add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 250, -1, -1));

        jLabel15.setFont(new java.awt.Font("Georgia", 1, 14)); // NOI18N
        jLabel15.setText("Lista de Funcionarios");
        getContentPane().add(jLabel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 40, -1, -1));

        jLabel16.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel16.setText("Informações Pessoais");
        getContentPane().add(jLabel16, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 250, -1, -1));

        jButton2.setText("Testar(Excluir)");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 210, -1, -1));

        jButtonSalvar.setText("Salvar");
        jButtonSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSalvarActionPerformed(evt);
            }
        });
        getContentPane().add(jButtonSalvar, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 550, 120, -1));

        jButtonCancelar.setText("Cancelar");
        jButtonCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCancelarActionPerformed(evt);
            }
        });
        getContentPane().add(jButtonCancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 550, 140, -1));
        getContentPane().add(jLabelCodigo, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 220, -1, -1));

        jLabel17.setFont(new java.awt.Font("MV Boli", 1, 18)); // NOI18N
        jLabel17.setText("Compre-Já");
        getContentPane().add(jLabel17, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed

    }//GEN-LAST:event_jButtonOKActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        ListarFuncionarios();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jTableFuncionarioMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableFuncionarioMouseClicked
        int posicao = jTableFuncionario.getSelectedRow();
        OpcaoFuncionario op = new OpcaoFuncionario();
        op.Recuperar(posicao);
        op.show();
    }//GEN-LAST:event_jTableFuncionarioMouseClicked

    private void jTextFieldNumeroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldNumeroActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldNumeroActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        try {
            Fachada f = new Fachada();
            this.funcionarios = f.ListarFuncionarios();
            Funcionario delete = this.funcionarios.get(3);
            System.out.print(delete);
            f.ExcluirFuncionario(delete);
            ListarFuncionarios();
            JOptionPane.showMessageDialog(null, "Dados removidos com Sucesso!");
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane, ex.getMessage());
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButtonSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSalvarActionPerformed
        String cargo = (String) jComboBoxCargo.getSelectedItem();
        String estado = (String) jComboBoxEstado.getSelectedItem();
        String cidade = (String) jComboBoxCidade.getSelectedItem();
        String sexo = (String) jComboBoxSexo.getSelectedItem();

        try {
            Funcionario fun = new Funcionario();
            fun.setId(Integer.parseInt(jLabelCodigo.getText()));
            fun.setSalario(Float.parseFloat(jTextFieldSalario.getText()));
            fun.setNome(jTextFieldNome.getText());
            fun.setCargo(cargo);
            fun.setSexo(sexo);
            fun.getEndereco().setRua(jTextFieldLogradouro.getText());
            fun.getEndereco().setCidade(cidade);
            fun.getEndereco().setEstado(estado);
            fun.getEndereco().setBairro(jTextFieldBairro.getText());
            fun.getEndereco().setComplemento(jTextFieldComplemento.getText());
            fun.setCpf(jTextFieldCPF.getText());
            fun.setRg(jTextFieldRG.getText());
            fun.setLogin(jTextFieldCPF.getText());
            fun.setSenha("");
            Fachada fachada = new Fachada();
            fachada.AlterarFuncionario(fun);
            OcultarAlterar();
            JOptionPane.showMessageDialog(rootPane, "Funcionario Alterado com sucesso");
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane, ex.getMessage());
        }
    }//GEN-LAST:event_jButtonSalvarActionPerformed

    private void jButtonCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelarActionPerformed
        ListarFuncionarios();
        OcultarAlterar();
    }//GEN-LAST:event_jButtonCancelarActionPerformed

    private void jComboBoxEstadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxEstadoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBoxEstadoActionPerformed

    private void ListarEstado(String estado) {
        try {
            if (null != estado) {
                switch (estado) {
                    case "PE": {
                        DefaultComboBoxModel modelo = new DefaultComboBoxModel();
                        modelo.addElement("PE");
                        modelo.addElement("AL");
                        modelo.addElement("BA");
                        modelo.addElement("PB");
                        modelo.addElement("MA");
                        jComboBoxCidade.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Recife"}));
                        jComboBoxEstado.setModel(modelo);
                        break;
                    }
                    case "PB": {
                        DefaultComboBoxModel modelo = new DefaultComboBoxModel();
                        modelo.addElement("PB");
                        modelo.addElement("AL");
                        modelo.addElement("BA");
                        modelo.addElement("PE");
                        modelo.addElement("MA");
                        jComboBoxCidade.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"João Pessoa"}));
                        jComboBoxEstado.setModel(modelo);
                        break;
                    }
                    case "AL": {
                        DefaultComboBoxModel modelo = new DefaultComboBoxModel();
                        modelo.addElement("AL");
                        modelo.addElement("BA");
                        modelo.addElement("PE");
                        modelo.addElement("PB");
                        modelo.addElement("MA");
                        jComboBoxCidade.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Maceío"}));
                        jComboBoxEstado.setModel(modelo);
                        break;
                    }
                    case "BA": {
                        DefaultComboBoxModel modelo = new DefaultComboBoxModel();
                        modelo.addElement("AL");
                        modelo.addElement("PE");
                        modelo.addElement("PB");
                        modelo.addElement("PB");
                        modelo.addElement("MA");
                        jComboBoxCidade.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Salvador"}));
                        jComboBoxEstado.setModel(modelo);
                        break;
                    }
                    case "MA": {
                        DefaultComboBoxModel modelo = new DefaultComboBoxModel();
                        modelo.addElement("MA");
                        modelo.addElement("AL");
                        modelo.addElement("BA");
                        modelo.addElement("PE");
                        modelo.addElement("PB");
                        jComboBoxCidade.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"São Luis"}));
                        jComboBoxEstado.setModel(modelo);
                        break;
                    }
                }
            }
            /*Fachada f = new Fachada();
             this.funcionarios = f.ListarFuncionarios();
             DefaultComboBoxModel modelo = new DefaultComboBoxModel();
             for (Funcionario fun : this.funcionarios) {
             modelo.addElement(fun.getEndereco().getCidade());
             }
             jComboBoxCidade.setModel(modelo);*/
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane, ex.getMessage());
        }
    }

    private void ListarSexo(String estado) {
        try {
            if (null != estado) {
                switch (estado) {
                    case "Masculino": {
                        DefaultComboBoxModel modelo = new DefaultComboBoxModel();
                        modelo.addElement("Masculino");
                        modelo.addElement("Feminino");
                        jComboBoxSexo.setModel(modelo);
                        break;
                    }
                    case "Feminino": {
                        DefaultComboBoxModel modelo = new DefaultComboBoxModel();
                        modelo.addElement("Feminino");
                        modelo.addElement("Masculino");
                        jComboBoxSexo.setModel(modelo);
                        break;
                    }

                }
            }

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane, ex.getMessage());
        }
    }

    private void ListarCargo(String estado) {
        try {
            if (null != estado) {
                switch (estado) {
                    case "Gestor de Clientes": {
                        DefaultComboBoxModel modelo = new DefaultComboBoxModel();
                        modelo.addElement("Gestor de Clientes");
                        modelo.addElement("Gestor de Produtos");
                        jComboBoxCargo.setModel(modelo);
                        break;
                    }
                    case "Gestor de Produtos": {
                        DefaultComboBoxModel modelo = new DefaultComboBoxModel();
                        modelo.addElement("Gestor de Produtos");
                        modelo.addElement("Gestor de Clientes");
                        jComboBoxCargo.setModel(modelo);
                        break;
                    }

                }
            }

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane, ex.getMessage());
        }
    }

    public void Alterar(int a) {
        try {
            ListarFuncionarios();
            ExibirAlterar();
            Fachada f = new Fachada();
            int posicao = a;
            this.funcionarios = f.ListarFuncionarios();
            int id = funcionarios.get(posicao).getId();
            jLabelCodigo.setText("" + id);
            String nome = funcionarios.get(posicao).getNome();
            jTextFieldNome.setText(nome);
            String cpf = funcionarios.get(posicao).getCpf();
            jTextFieldCPF.setText(cpf);
            String rg = funcionarios.get(posicao).getRg();
            jTextFieldRG.setText(rg);
            String bairro = funcionarios.get(posicao).getEndereco().getBairro();
            jTextFieldBairro.setText(bairro);
            String logradouro = funcionarios.get(posicao).getEndereco().getRua();
            jTextFieldLogradouro.setText(logradouro);
            String estado = funcionarios.get(posicao).getEndereco().getEstado();
            ListarEstado(estado);
            String sexo = funcionarios.get(posicao).getSexo();
            ListarSexo(sexo);
            String cargo = funcionarios.get(posicao).getCargo();
            ListarCargo(cargo);
            int numero = funcionarios.get(posicao).getEndereco().getNumero();
            jTextFieldNumero.setText("" + numero);
            String complemento = funcionarios.get(posicao).getEndereco().getComplemento();
            jTextFieldComplemento.setText(complemento);
            double preco = funcionarios.get(posicao).getSalario();
            jTextFieldSalario.setText("" + preco);
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane, ex.getMessage());
        }
    }

    public void Excluir(int b) {
        try {
            Fachada f = new Fachada();
            this.funcionarios = f.ListarFuncionarios();
            Funcionario delete = this.funcionarios.get(b);
            f.ExcluirFuncionario(delete);
            ListarFuncionarios();
            JOptionPane.showMessageDialog(null, "Dados removidos com Sucesso!");
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane, ex.getMessage());
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ExcluirAlterarFuncionario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ExcluirAlterarFuncionario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ExcluirAlterarFuncionario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ExcluirAlterarFuncionario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ExcluirAlterarFuncionario().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButtonCancelar;
    private javax.swing.JButton jButtonOK;
    private javax.swing.JButton jButtonSalvar;
    private javax.swing.JButton jButtonVoltar;
    private javax.swing.JComboBox jComboBoxCargo;
    private javax.swing.JComboBox jComboBoxCidade;
    private javax.swing.JComboBox jComboBoxEstado;
    private javax.swing.JComboBox jComboBoxSexo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelCodigo;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JTable jTableFuncionario;
    private javax.swing.JTextField jTextFieldBairro;
    private javax.swing.JTextField jTextFieldCPF;
    private javax.swing.JTextField jTextFieldComplemento;
    private javax.swing.JTextField jTextFieldLogradouro;
    private javax.swing.JTextField jTextFieldNome;
    private javax.swing.JTextField jTextFieldNumero;
    private javax.swing.JTextField jTextFieldRG;
    private javax.swing.JTextField jTextFieldSalario;
    // End of variables declaration//GEN-END:variables
}
